/*
function getCaretPosition(input)
{
var result = { start: 0, end: 0 };
if (input.setSelectionRange)
{
result.texto = document.getSelection();
result.start = input.selectionStart;
result.end = input.selectionEnd;
}
else if (document.selection && document.selection.createRange)
{
var range = document.selection.createRange();
var r2 = range.duplicate();
result.start = 0 - r2.moveStart('character', -100000);
result.end = result.start + range.text.length;
result.start = result.start - 1;
result.end = result.end - 1;
result.texto = range.text;
}
return result;
}

function display(id_texto, txtarea, result) {
var i =  result.start;
var f =  result.end;
document.getElementById('inicio').value = i;
document.getElementById('fim').value = f;
var texto = txtarea.innerHTML;
var palavra = texto.substr(i,(f-i));

//document.getElementById('palavra').value = palavra;	
document.getElementById("palavra_label").innerHTML = palavra;
document.getElementById('aviso').style.display = 'none';	
document.getElementById('lacuna_atual').style.display = 'inline';
}
*/


	$(document).ready(function() {
		$('.texto_selecionavel').keydown(update).keyup(update).mousedown(update).mouseup(update).mousemove(update);
	});
	
	function update() {
	
	var range = $(this).getSelection();
	
	//replace(/[\r\n]/g,"");
	
	document.getElementById("aviso").style.display = 'none';		
	//document.getElementById("palavra").value = range.text; 
	document.getElementById('inicio').value = range.start;
	document.getElementById('fim').value =  range.end;
	document.getElementById("palavra_label").innerHTML = range.text;
	
	document.getElementById("lacuna_atual").style.display = 'inline';
	

	}

